#hasattr
Description: Check if an attribute exists. See also: delattr, getattr, setattr
def hasattr(obj, name: str):
'''
Check if an attribute exists
:param obj: An object
:param name: The name of the attribute
:return: True if the attribute exists, otherwise False
'''
Example:
class Person:
def __init__(self, name, age):
self.name = name
self.age = age
p = Person("Alice", 30)
print(hasattr(p, 'name')) # True
print(hasattr(p, 'age')) # True
print(hasattr(p, 'sex')) # False